Skip to content

fix(ios): apply camera updates made while the map is off-window; replace deprecated image context - #4308

Merged
mfazekas merged 2 commits into
mainfrom
claude/issue-4296-9jvilr
Oct 4, 2026
Merged

mfazekas merged 2 commits into
mainfrom
claude/issue-4296-9jvilr

Conversation

@mfazekas

@mfazekas mfazekas commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Miklós · project thread

Description

Fixes #4304
Refs #4260 (cleanup only, crash not reproduced)

Two small iOS changes, one commit each (happy to split into two PRs).

#4260, deprecated image context in Images and takeSnap. RNMBXImages.placeholderImage force-unwrapped UIGraphicsGetImageFromCurrentImageContext(), which traps when the legacy context can't be created. It now uses UIGraphicsImageRenderer, the same pattern already used in RNMBXNativeUserLocation, RNMBXImage and RNMBXPointAnnotation. RNMBXMapView.takeSnap had the same force-unwrap and gets the same change.

#4304, camera prop change on a detached map is lost. Mapbox's MapView.didMoveToWindow sets cameraAnimatorsRunner.isEnabled = false when window == nil, and the runner then cancels new animations immediately (checked in mapbox-maps-ios v11.23.1, CameraAnimatorsRunner.swift). So flyTo/easeTo/linearTo stops sent while the screen is inactive were dropped. moveTo works because it uses setCamera. CameraUpdateItem.execute now jumps with setCamera when the map view has no window, which matches what Android does.

Checklist

  • I've read CONTRIBUTING.md
  • I updated the doc/other generated code with running yarn generate in the root folder (no generated code affected)
  • I have tested the new feature on /example app.
    • In V11 mode/ios
    • In New Architecture mode/ios
    • In V11 mode/android (iOS-only change)
    • In New Architecture mode/android (iOS-only change)
  • I added/updated a sample - if a new feature was implemented (/example)

Verification

The example app ran on an iPhone 17 Pro simulator (iOS 26.5, Xcode 26.6, MapboxMaps 11.23.1), with the reproducer components from the issues added temporarily. Both builds compiled with no errors or warnings.

#4304. I used the component from the issue, which reads getCenter() 5s after the screen is re-attached (A = -74.0060, 40.7143 and B = -73.9500, 40.7800).

run main this PR
#1-#3 default mode -74.0060, 40.7143 (stays at A) -73.9500, 40.7800 (B)
#4-#5 moveTo -73.9500, 40.7800 (B) -73.9500, 40.7800 (B)

#4260. This did not reproduce on the simulator or on a physical iPhone 13 mini running iOS 26.6.2 (Release builds of main and this PR):

  • The issue's snippet never evaluates placeholderImage. For a new URL image, addImages(oldImages: [:]) skips the placeholder branch. The placeholder is only built when images are re-added after an image has loaded but is missing from the style.
  • When placeholderImage was forced on main, the deprecated UIGraphicsBeginImageContextWithOptions path returned a valid 1x1 image on iOS 26.6.2. takeSnap(false) returned an image on both builds, and there were no crash logs.

So the root cause in #4260 is unconfirmed. The commit stays as a cleanup that removes a deprecated API and two force-unwraps, but it does not claim to close the issue.

Component to reproduce the issue you're fixing

See the components in #4260 and #4304.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GEzQRvQdtNT3hmJhbB3xp3

mfazekas and others added 2 commits October 4, 2026 11:56
…text

The Images placeholder force-unwrapped UIGraphicsGetImageFromCurrentImageContext(),
which traps when the context can't be created (reported on iOS 26). takeSnap had
the same pattern. Fixes #4260.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GEzQRvQdtNT3hmJhbB3xp3
Mapbox cancels camera animations immediately while MapView has no window, so
animated Camera stop updates issued on an inactive screen were dropped. Jump to
the target instead. Fixes #4304.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GEzQRvQdtNT3hmJhbB3xp3
@mfazekas mfazekas self-assigned this Oct 4, 2026
@mfazekas mfazekas changed the title fix(ios): Images placeholder crash on iOS 26, and camera updates dropped while off-window fix(ios): apply camera updates made while the map is off-window; replace deprecated image context Oct 4, 2026
@mfazekas
mfazekas marked this pull request as ready for review October 4, 2026 13:02
@mfazekas
mfazekas merged commit 28047c4 into main Oct 4, 2026
6 checks passed
@mfazekas
mfazekas deleted the claude/issue-4296-9jvilr branch October 4, 2026 13:21

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: iOS: Camera prop change while MapView is detached from the window is never applied (animated modes)

1 participant